package com.edu.web.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.edu.entity.PageBean;
import com.edu.entity.User;
import com.edu.entity.shopDingdong;
import com.edu.service.UserBackgroundService;
import com.edu.service.impl.UserBackgroundServiceImpl;

/**
 * Servlet implementation class FenYeShop
 */
@WebServlet("/FenYeShopServlet")
public class FenYeShopServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FenYeShopServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		
		UserBackgroundService userBackService = new UserBackgroundServiceImpl();
		String result = request.getParameter("currentPageNum");
		String pageSizeS = request.getParameter("pageSize");
		
		int currentPageNum = Integer.parseInt(result==null?"1":result);
		int pageSize = Integer.parseInt(pageSizeS==null?"5":pageSizeS);//显示记录数

		PageBean<shopDingdong> data = userBackService.queryShop(currentPageNum, pageSize,"shopdingdong");
		request.setAttribute("PageBean", data);

		//request.setAttribute("PageBean", data);//总页数
		request.getRequestDispatcher("iframeShop.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
